#pragma comment(linker, "/STACK:10000000")
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
#include <string>
#include <cstring>
#define ldb long double
#define LL long long
#define fi first
#define se second
#define fill(a, c) memset(a, c, sizeof(a))
#define sqr(a) ((a) * (a))
#define nextLine() {int c = 0; while((c = getchar()) != 10 && c != EOF);}
#define getBit(mask, k) (((mask) / pw[k]) % pw[1])
#define setBit(mask, k, l) (((mask) / pw[k + 1] * pw[1] + (l)) * pw[k] + ((mask) % pw[k]))
#define debug(a) cerr << #a << " = " << a << " ";
#define debugl(a) cerr << #a << " = " << a << "\n";
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define ff first
#define ss second 
const ldb LDINF = 9128739847123.00;
const ldb eps = 1e-9;
const int inf = 1 << 28;
const ldb pi = fabsl(atan2l(0.0, -1.0));
using namespace std;

int a[2];
int n;


void load()
{
	cin >> a[0] >> a[1] >> n;
}

int dp[111][2];

int f(int n, int who)
{
	if (n < 0) return 1;
	if (dp[n][who] != -1) return dp[n][who];
	int d = __gcd(a[who], n);
	dp[n][who] = f(n - d, who ^ 1) ^ 1;
/*	for (int i = 1; i * i <= n; i++)
	{
		if (n % i == 0 && a[who] % i == 0)
		{
			if (!f(n - i, who ^ 1))
			{
				dp[n][who] = 1;
				return 1;
			}
		}
		if (n % i == 0 && a[who] %( n / i) == 0)
		{
			if (!f(n - n / i, who ^ 1))
			{
				dp[n][who] = 1;
				return 1;
			}
		}
	}
	*/
	return dp[n][who];
}

void solve()
{
	memset(dp, -1, sizeof(dp));
	if (f(n, 0))
		cout << "0";
		else cout << 1;
}

#define file "a"
int main()
{
	#ifndef ONLINE_JUDGE
		freopen(file".in", "rt", stdin);
		freopen(file".out", "wt", stdout);
	#endif
	load();
	solve();
	return 0;
}
